﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OilFillRecordForm.aspx.cs"
    Inherits="YhmOA.Integrated.Car.OilFillRecordForm" %>
<%@ Register Assembly="DevExpress.Web.v10.1, Version=10.1.6.0, Culture=neutral, PublicKeyToken=c6bed6029ccaee5e"
    Namespace="DevExpress.Web.ASPxHiddenField" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v10.1, Version=10.1.6.0, Culture=neutral, PublicKeyToken=c6bed6029ccaee5e"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v10.1, Version=10.1.6.0, Culture=neutral, PublicKeyToken=c6bed6029ccaee5e"
    Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v10.1, Version=10.1.6.0, Culture=neutral, PublicKeyToken=c6bed6029ccaee5e"
    Namespace="DevExpress.Web.ASPxLoadingPanel" TagPrefix="dx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link type="text/css" rel="Stylesheet" href="../../Styles/Common.css" />
    <script type="text/javascript" src="../../Scripts/jquery-1.5.2.min.js"></script>
    <script type="text/javascript" src="../../Scripts/include.jquery.js"></script>
    <script type="text/javascript" src="../../Scripts/Common.js"></script>
    <script src="../../Scripts/DevEx.js" type="text/javascript"></script>
    <script type="text/javascript">
        function OnCashSelected() {
            txt_OilCardSNCtrl.SetText("");
            txt_OilCardMoneyCtrl.SetText("");
            txt_OilCardRemainMoneyCtrl.SetText("");
            txt_OilCardSNCtrl.SetEnabled(false);
            txt_OilCardMoneyCtrl.SetEnabled(false);
            txt_OilCardRemainMoneyCtrl.SetEnabled(false);
        };
        function OnCardSelected() {
            txt_OilCardSNCtrl.SetEnabled(true);
            txt_OilCardMoneyCtrl.SetEnabled(true);
            txt_OilCardRemainMoneyCtrl.SetEnabled(true);
        };
        function OnOilCardChanged(s, e) {
            if (txt_OilCardSNCtrl.GetSelectedIndex() > -1) {
                txt_OilCardMoneyCtrl.SetText(txt_OilCardSNCtrl.GetValue());
            } else {
                txt_OilCardMoneyCtrl.SetText('');
            }
            txt_OilCardRemainMoneyCtrl.SetText("");
            txt_CostCtrl.SetText("");
            txt_CurrentVolumeCtrl.SetText("");
        };
        function Save(s, e) {
            if (ASPxClientEdit.ValidateEditorsInContainer(null)) {
                if (GetQS("mode") == "1") {
                    ConfirmDialog('提示信息', '是否要自动生成一条费用记录?', 250, 180,
                    function () {
                        cbSaveCtrl.PerformCallback('true');
                        lpSaveCtrl.Show();
                        $(this).wijdialog('close');
                    },
                    function () {
                        cbSaveCtrl.PerformCallback('false');
                        lpSaveCtrl.Show();
                        $(this).wijdialog('close');
                    });
                } else {
                    cbSaveCtrl.PerformCallback('true');
                    lpSaveCtrl.Show();
                    $(this).wijdialog('close');
                }
            }
        };
        function SaveCallback(s, e) {
            if (s.cpIsSucceed == true) {
                lpSaveCtrl.SetText('提交成功');
                parent.Search();
                window.setTimeout(function () { lpSaveCtrl.Hide(); lpSaveCtrl.SetText('正在提交信息,请稍后...'); }, 1500);
            } else {
                lpSaveCtrl.SetText('提交失败');
                window.setTimeout(function () { lpSaveCtrl.Hide(); lpSaveCtrl.SetText('正在提交信息,请稍后...'); }, 1500);
            }
        };
        function OnPriceChanged() {
            txt_OilCardRemainMoneyCtrl.SetText("");
            txt_CostCtrl.SetText("");
            txt_CurrentVolumeCtrl.SetText("");
        };
        function OnCardRemainMoneyChanged() {
            if (parseFloat(txt_OilCardMoneyCtrl.GetText()) > 0 && parseFloat(txt_OilCardRemainMoneyCtrl.GetText()) > 0) {
                txt_CostCtrl.SetText((parseFloat(txt_OilCardMoneyCtrl.GetText()).toFixed(4) - 0) - (parseFloat(txt_OilCardRemainMoneyCtrl.GetText()).toFixed(4) - 0));
            }
            if (parseFloat(txt_PriceCtrl.GetText()) > 0 && parseFloat(txt_CostCtrl.GetText()) > 0) {
                txt_CurrentVolumeCtrl.SetText(((parseFloat(txt_CostCtrl.GetText()).toFixed(4) - 0) / (parseFloat(txt_PriceCtrl.GetText()).toFixed(4) - 0)).toFixed(4));
            }
        };
        function OnCostChanged() {
            if (txt_OilCardSNCtrl.GetVisible()) {
                if (parseFloat(txt_OilCardMoneyCtrl.GetText()) > 0 && parseFloat(txt_CostCtrl.GetText()) > 0) {
                    txt_OilCardRemainMoneyCtrl.SetText((parseFloat(txt_OilCardMoneyCtrl.GetText()).toFixed(4) - 0) - (parseFloat(txt_CostCtrl.GetText()).toFixed(4) - 0));
                }
            }
            if (parseFloat(txt_PriceCtrl.GetText()) > 0 && parseFloat(txt_CostCtrl.GetText()) > 0) {
                txt_CurrentVolumeCtrl.SetText(((parseFloat(txt_CostCtrl.GetText()).toFixed(4) - 0) / (parseFloat(txt_PriceCtrl.GetText()).toFixed(4) - 0)).toFixed(4));
            }
        };
        function OnCurrentVolumeChanged() {
            if (parseFloat(txt_PriceCtrl.GetText()) > 0 && parseFloat(txt_CurrentVolumeCtrl.GetText()) > 0) {
                txt_CostCtrl.SetText(((parseFloat(txt_CurrentVolumeCtrl.GetText()).toFixed(4) - 0) * (parseFloat(txt_PriceCtrl.GetText()).toFixed(4) - 0)).toFixed(4));
            }
            if (txt_OilCardSNCtrl.GetVisible()) {
                if (parseFloat(txt_OilCardMoneyCtrl.GetText()) > 0 && parseFloat(txt_CostCtrl.GetText()) > 0) {
                    txt_OilCardRemainMoneyCtrl.SetText((parseFloat(txt_OilCardMoneyCtrl.GetText()).toFixed(4) - 0) - (parseFloat(txt_CostCtrl.GetText()).toFixed(4) - 0));
                }
            }
        };
        window.onload = function () {
            var cardCrshFlag = HidFieldCtrl.Get("CardCrshFlag");
            if (cardCrshFlag == "XJ" || cardCrshFlag == "None") {
                txt_OilCardSNCtrl.SetEnabled(false);
                txt_OilCardMoneyCtrl.SetEnabled(false);
                txt_OilCardRemainMoneyCtrl.SetEnabled(false);
                $("#rb_Cash").attr("checked", true);
            }
            else {
                $("#rb_Card").attr("checked", true);
            }
        };
        //重置文本框
        function ResetEdit(s, e) {
            ASPxClientEdit.ClearEditorsInContainer(null);
            txt_OilTypeCtrl.Focus();
            txt_AddressCtrl.Focus();
            txt_OperatorCtrl.Focus();
            txt_PlateNumCtrl.Focus();
            lpSaveCtrl.SetText('正在提交信息,请稍后...');
        };
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="MainRound">
        <div class="MainRoundContent">
            <div class="MainRoundContentW">
                <div class="MainBody">
                    <table class="Table" style="width: 740px">
                        <tr>
                            <td style="width: 120px">
                                车牌号码：
                            </td>
                            <td style="width: 250px" colspan="2">
                                <dx:ASPxComboBox ID="txt_PlateNum" runat="server" Width="200px" TabIndex="1" ClientInstanceName="txt_PlateNumCtrl"
                                    Spacing="0" DropDownStyle="DropDown" IncrementalFilteringMode="StartsWith" ClientIDMode="AutoID"
                                    ValueType="System.String">
                                    <ClientSideEvents Init="DevExObj.OnInit" LostFocus="DevExObj.OnLostFocus" GotFocus="DevExObj.OnGotFocus" />
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请输入车牌号码"
                                        ErrorFrameStyle-CssClass="TableNoBorder" ErrorText="请输入车牌号码">
                                        <RequiredField IsRequired="True" />
                                    </ValidationSettings>
                                </dx:ASPxComboBox>
                            </td>
                            <td style="width: 120px">
                                油类：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxComboBox ID="txt_OilType" ClientInstanceName="txt_OilTypeCtrl" runat="server"
                                    Width="200px" TabIndex="2" CssClass="TableNoBorder" Spacing="0">
                                    <Items>
                                        <dx:ListEditItem Text="汽油(97#)" Value="汽油(97#)" />
                                        <dx:ListEditItem Text="汽油(95#)" Value="汽油(95#)" />
                                        <dx:ListEditItem Text="汽油(93#)" Value="汽油(93#)" />
                                        <dx:ListEditItem Text="汽油(90#)" Value="汽油(90#)" />
                                        <dx:ListEditItem Text="柴油(0#)" Value="柴油(0#)" />
                                        <dx:ListEditItem Text="柴油(-10#)" Value="柴油(-10#)" />
                                        <dx:ListEditItem Text="柴油(-20#)" Value="柴油(-20#)" />
                                        <dx:ListEditItem Text="其他" Value="其他" />
                                    </Items>
                                    <ClientSideEvents Init="DevExObj.OnInit" LostFocus="DevExObj.OnLostFocus" GotFocus="DevExObj.OnGotFocus" />
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请选择油类"
                                        ErrorFrameStyle-CssClass="TableNoBorder" ErrorText="请选择油类">
                                        <RequiredField IsRequired="True" />
                                    </ValidationSettings>
                                </dx:ASPxComboBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 120px">
                                加油时间：
                            </td>
                            <td style="width: 250px" colspan="2">
                                <dx:ASPxDateEdit ID="txt_Time" ClientInstanceName="txt_TimeCtrl" runat="server" TabIndex="3"
                                    NullText="请选择加油时间" Width="200px" Spacing="0" EditFormat="DateTime" PopupVerticalAlign="TopSides">
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请选择加油时间"
                                        ErrorFrameStyle-CssClass="TableNoBorder">
                                        <RequiredField IsRequired="True" />
                                    </ValidationSettings>
                                    <NullTextStyle ForeColor="LightSteelBlue" />
                                </dx:ASPxDateEdit>
                            </td>
                            <td style="width: 120px">
                                加油地点：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxComboBox ID="txt_Address" runat="server" Width="200px" TabIndex="4" ClientInstanceName="txt_AddressCtrl"
                                    Spacing="0" DropDownStyle="DropDown" IncrementalFilteringMode="StartsWith" ClientIDMode="AutoID"
                                    ValueType="System.String">
                                    <ClientSideEvents Init="DevExObj.OnInit" LostFocus="DevExObj.OnLostFocus" GotFocus="DevExObj.OnGotFocus" />
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请输入加油地点"
                                        ErrorFrameStyle-CssClass="TableNoBorder" ErrorText="请输入加油地点">
                                        <RequiredField IsRequired="True" />
                                    </ValidationSettings>
                                </dx:ASPxComboBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 120px">
                                付款方式：
                            </td>
                            <td style="width: 250px" colspan="2">
                                <input id="rb_Cash" type="radio" name="PayType" checked="checked" tabindex="6" onclick="OnCashSelected()">现金</input>
                                <input id="rb_Card" type="radio" name="PayType" tabindex="7" onclick="OnCardSelected()">加油卡</input>
                            </td>
                            <td style="width: 120px">
                                单价：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxTextBox ID="txt_Price" ClientInstanceName="txt_PriceCtrl" runat="server"
                                    MaxLength="9" NullText="请输入单价" TabIndex="8" Width="200px">
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请输入单价"
                                        ErrorFrameStyle-CssClass="TableNoBorder">
                                        <RequiredField IsRequired="True" />
                                        <RegularExpression ErrorText="只能输入非负数字" ValidationExpression="^\d+(\.\d+)?$" />
                                    </ValidationSettings>
                                    <ClientSideEvents TextChanged="OnPriceChanged" />
                                    <NullTextStyle ForeColor="LightSteelBlue" />
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr id="tr_card">
                            <td style="width: 120px">
                                加油卡号及余额：
                            </td>
                            <td style="width: 125px" class="TableNoBorder">
                                <dx:ASPxComboBox ID="txt_OilCardSN" runat="server" Width="125px" TabIndex="9" ClientInstanceName="txt_OilCardSNCtrl"
                                    Spacing="0" DropDownStyle="DropDownList" IncrementalFilteringMode="StartsWith"
                                    ClientIDMode="AutoID" ValueType="System.String" TextFormatString="{0}" ValueField="Money">
                                    <Columns>
                                        <dx:ListBoxColumn FieldName="SN" Caption="卡号" />
                                         <dx:ListBoxColumn FieldName="Money" Caption="余额" />
                                    </Columns>
                                    <ClientSideEvents Init="DevExObj.OnInit" LostFocus="DevExObj.OnLostFocus" GotFocus="DevExObj.OnGotFocus" 
                                     TextChanged="OnOilCardChanged" />
                                </dx:ASPxComboBox>
                                </td>
                            <td style="width: 125px" class="TableNoBorder">
                                <dx:ASPxTextBox ID="txt_OilCardMoney" ClientInstanceName="txt_OilCardMoneyCtrl" runat="server"
                                    MaxLength="9" Width="72px" ReadOnly="true">
                                </dx:ASPxTextBox>
                            </td>
                            <td style="width: 120px">
                                加油后卡内余额：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxTextBox ID="txt_OilCardRemain" ClientInstanceName="txt_OilCardRemainMoneyCtrl"
                                    runat="server" MaxLength="9" NullText="请输入加油后卡内余额" TabIndex="10" Width="200px">
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请输入加油后卡内余额"
                                        ErrorFrameStyle-CssClass="TableNoBorder">
                                        <RequiredField IsRequired="True" />
                                        <RegularExpression ErrorText="只能输入非负数字" ValidationExpression="^\d+(\.\d+)?$" />
                                    </ValidationSettings>
                                    <NullTextStyle ForeColor="LightSteelBlue" />
                                    <ClientSideEvents TextChanged="OnCardRemainMoneyChanged" />
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 120px">
                                加油费用：
                            </td>
                            <td style="width: 250px" colspan="2">
                                <dx:ASPxTextBox ID="txt_Cost" ClientInstanceName="txt_CostCtrl" runat="server" MaxLength="9"
                                    NullText="请输入加油费用" TabIndex="14" Width="200px">
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请输入加油费用"
                                        ErrorFrameStyle-CssClass="TableNoBorder">
                                        <RequiredField IsRequired="True" />
                                        <RegularExpression ErrorText="只能输入非负数字" ValidationExpression="^\d+(\.\d+)?$" />
                                    </ValidationSettings>
                                    <ClientSideEvents TextChanged="OnCostChanged" />
                                    <NullTextStyle ForeColor="LightSteelBlue" />
                                </dx:ASPxTextBox>
                            </td>
                            <td style="width: 120px">
                                本次加油量：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxTextBox ID="txt_CurrentVolume" ClientInstanceName="txt_CurrentVolumeCtrl"
                                    runat="server" MaxLength="9" NullText="请输入本次加油量" TabIndex="11" Width="200px">
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请输入本次加油量"
                                        ErrorFrameStyle-CssClass="TableNoBorder">
                                        <RequiredField IsRequired="True" />
                                        <RegularExpression ErrorText="只能输入非负数字" ValidationExpression="^\d+(\.\d+)?$" />
                                    </ValidationSettings>
                                    <ClientSideEvents TextChanged="OnCurrentVolumeChanged" />
                                    <NullTextStyle ForeColor="LightSteelBlue" />
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 120px">
                                本次加油时里程：
                            </td>
                            <td style="width: 250px" colspan="2">
                                <dx:ASPxTextBox ID="txt_CurrentMileage" ClientInstanceName="txt_CurrentMileageCtrl"
                                    runat="server" MaxLength="9" NullText="请输入本次加油时里程" TabIndex="13" Width="200px">
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请输入本次加油时里程"
                                        ErrorFrameStyle-CssClass="TableNoBorder">
                                        <RequiredField IsRequired="True" />
                                        <RegularExpression ErrorText="只能输入非负数字" ValidationExpression="^\d+(\.\d+)?$" />
                                    </ValidationSettings>
                                    <NullTextStyle ForeColor="LightSteelBlue" />
                                </dx:ASPxTextBox>
                            </td>
                            <td style="width: 120px">
                                本次平均油耗：
                            </td>
                            <td style="width: 250px">
                                
                                <dx:ASPxTextBox ID="txt_CurrentAvgOil" ClientInstanceName="txt_CurrentAvgOilCtrl"
                                    runat="server" MaxLength="9" NullText="请输入本次平均油耗" TabIndex="12" Width="200px">
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请输入本次平均油耗"
                                        ErrorFrameStyle-CssClass="TableNoBorder">
                                        <RequiredField IsRequired="True" />
                                        <RegularExpression ErrorText="只能输入非负数字" ValidationExpression="^\d+(\.\d+)?$" />
                                    </ValidationSettings>
                                    <NullTextStyle ForeColor="LightSteelBlue" />
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                        <td style="width: 120px">
                                经办人：
                            </td>
                            <td style="width: 250px" colspan="2">
                                <dx:ASPxComboBox ID="txt_Operator" runat="server" Width="200px" TabIndex="15" ClientInstanceName="txt_OperatorCtrl"
                                    Spacing="0" DropDownStyle="DropDown" IncrementalFilteringMode="StartsWith" ClientIDMode="AutoID"
                                    ValueType="System.String">
                                    <ClientSideEvents Init="DevExObj.OnInit" LostFocus="DevExObj.OnLostFocus" GotFocus="DevExObj.OnGotFocus" />
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请输入经办人"
                                        ErrorFrameStyle-CssClass="TableNoBorder" ErrorText="请输入经办人">
                                        <RequiredField IsRequired="True" />
                                    </ValidationSettings>
                                </dx:ASPxComboBox>
                            </td>
                            <td style="width: 120px">
                                备注：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxTextBox ID="txt_Remarks" ClientInstanceName="txt_RemarksCtrl" runat="server"
                                    MaxLength="250" NullText="请输入备注" TabIndex="16" Width="200px">
                                    <NullTextStyle ForeColor="LightSteelBlue" />
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                    </table>
                    <br />
                    <table class="TableNoBorder" style="width: 740px">
                        <tr>
                            <td colspan="2" />
                            <td align="left" style="margin-right: 20px; width: 100px">
                                <dx:ASPxButton ID="btnSave" runat="server" Text="保  存" Width="80px" AutoPostBack="false"
                                    TabIndex="17">
                                    <ClientSideEvents Click="Save" />
                                </dx:ASPxButton>
                            </td>
                            <td align="left" style="margin-right: 20px; width: 100px">
                                <dx:ASPxButton ID="btnCancel" runat="server" Text="重  置" Width="80px" TabIndex="18"
                                    AutoPostBack="false">
                                    <ClientSideEvents Click="ResetEdit" />
                                </dx:ASPxButton>
                            </td>
                        </tr>
                    </table>
                    <dx:ASPxCallback ID="cbSave" runat="server" ClientInstanceName="cbSaveCtrl" OnCallback="cbSave_Callback">
                        <ClientSideEvents CallbackComplete="SaveCallback" />
                    </dx:ASPxCallback>
                    <dx:ASPxLoadingPanel ID="lpSave" runat="server" Text="正在提交信息,请稍后..." ClientInstanceName="lpSaveCtrl">
                    </dx:ASPxLoadingPanel>
                    <dx:ASPxHiddenField ID="HidField" ClientInstanceName="HidFieldCtrl" runat="server">
                    </dx:ASPxHiddenField>
                </div>
            </div>
        </div>
    </div>
    </form>
</body>
</html>
